﻿using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.Metadata.Entity
{
    public class MetaDataExtProperty:ICloneable
    {
        //枚举
        public string FieldDataType { get; set; }
        public string FieldName { get; set; }
        public object FieldValue { get; set; }
        /// <summary>
        /// 枚举
        /// </summary>
        public string ExtSource { get; set; }
        public string TableName { get; set; }
        public string ColumnName { get; set; }

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        public object GetValue()
        {
            switch (this.FieldDataType.ToLower())
            {
                case "string":
                    return Convert.ToString(FieldValue);
                case "int":
                    return Convert.ToInt32(FieldValue);
                case "bool":
                    return Convert.ToString(FieldValue);
                case "datetime":
                    try
                    {
                        return Convert.ToDateTime(FieldValue) == DateTime.MinValue ? DateTime.Parse("1900-01-01") : Convert.ToDateTime(FieldValue);
                    }
                    catch (Exception ex)
                    {
                        return DateTime.Parse("1900-01-01");
                    }
                default: return "";
            }
        }
    }
}
